package com.fzg.controller;


import com.fzg.common.enums.ResponseWrapper;
import com.fzg.common.model.param.diary.AddDiaryParam;
import com.fzg.common.model.param.diary.CommentPublishParam;
import com.fzg.common.model.param.diary.GetDiaryListParam;
import com.fzg.common.model.param.diary.GetOtherUserDiaryList;
import com.fzg.service.DiaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fzg
 * @since 2022-06-20
 */
@RestController
@RequestMapping("/diary")
public class DiaryController {

    @Autowired
    private DiaryService diaryService;

    /**
     * 获取(自己的)日记列表
     * @param param 参数
     * @return ResponseWrapper
     */
    @GetMapping("/getDiaryListApi")
    public ResponseWrapper getDiaryListApi(HttpServletRequest request, GetDiaryListParam param){
        return diaryService.getDiaryListApi(request,param);
    }

    /**
     * 获取(其他人的)日记列表
     * @param param 参数
     * @return ResponseWrapper
     */
    @GetMapping("/getOtherUserDiaryList")
    public ResponseWrapper getOtherUserDiaryList(GetOtherUserDiaryList param){
        return diaryService.getOtherUserDiaryList(param);
    }

    /**
     * 根据日记aid后端获取日记相关的所有信息
     * @return ResponseWrapper
     */
    @GetMapping("/getDiaryAllInfoByAid")
    public ResponseWrapper getDiaryAllInfoByAid(HttpServletRequest request,Integer aid){
        return diaryService.getDiaryAllInfoByAid(request,aid);
    }

    /**
     * 点击关注作者
     * @return ResponseWrapper
     */
    @GetMapping("/concernUser")
    public ResponseWrapper concernUser(HttpServletRequest request,Integer aid){
        return diaryService.concernUser(request,aid);
    }

    /**
     * 取消关注作者
     * @return ResponseWrapper
     */
    @GetMapping("/cancelConcernUser")
    public ResponseWrapper cancelConcernUser(HttpServletRequest request,Integer aid){
        return diaryService.cancelConcernUser(request,aid);
    }

    /**
     * 当前登陆的用户给这条日记点赞
     * @return ResponseWrapper
     */
    @GetMapping("/thumbsUpToDiary")
    public ResponseWrapper thumbsUpToDiary(HttpServletRequest request,Integer aid){
        return diaryService.thumbsUpToDiary(request,aid);
    }

    /**
     * 当前登陆用户给这条日记取消点赞
     * @return ResponseWrapper
     */
    @GetMapping("/cancelThumbsUpToDiary")
    public ResponseWrapper cancelThumbsUpToDiary(HttpServletRequest request,Integer aid){
        return diaryService.cancelThumbsUpToDiary(request,aid);
    }

    /**
     * 点击评论里面的赞，改变赞的状态
     * @return ResponseWrapper
     */
    @GetMapping("/clickCommentLike")
    public ResponseWrapper clickCommentLike(HttpServletRequest request,Integer aid){
        return diaryService.clickCommentLike(request,aid);
    }

    /**
     * 发表评论
     * @return ResponseWrapper
     */
    @PostMapping("/diaryCommentPublish")
    public ResponseWrapper diaryCommentPublish(HttpServletRequest request,@RequestBody CommentPublishParam param){
        return diaryService.diaryCommentPublish(request,param);
    }

    /**
     * 获取系统给当前登陆的用户推荐的所有日记列表
     * @return ResponseWrapper
     */
    @GetMapping("/getRecommentDiaryList")
    public ResponseWrapper getRecommentDiaryList(HttpServletRequest request){
        return diaryService.getRecommentDiaryList(request);
    }

    /**
     * 获取当前登陆这个用户关注的所有用户的所有日记列表
     * @return ResponseWrapper
     */
    @GetMapping("/getCurrentUserConcernUserDiaryList")
    public ResponseWrapper getCurrentUserConcernUserDiaryList(HttpServletRequest request){
        return diaryService.getCurrentUserConcernUserDiaryList(request);
    }

    /**
     * 添加或者编辑日记
     * @return ResponseWrapper
     */
    @PostMapping("/addOrEditDiary")
    public ResponseWrapper addOrEditDiary(HttpServletRequest request,@RequestBody AddDiaryParam param){
        return diaryService.addOrEditDiary(request, param);
    }



}
